package com.eightbears.beboy.adapter;

import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.eightbears.beboy.R;
import com.eightbears.beboy.entity.ShopTechnicianEntity;

import java.util.List;


//技师列表
public class TechnicianManagerAdapter extends BaseQuickAdapter<ShopTechnicianEntity.DataBean.ListBean, BaseViewHolder> {

    public TechnicianManagerAdapter(Context context) {
        super(R.layout.item_shop_technician_manage, null);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, ShopTechnicianEntity.DataBean.ListBean listBean) {

        if (!TextUtils.isEmpty(listBean.getUser_id())) {
            baseViewHolder.getView(R.id.iv_hips).setVisibility(View.VISIBLE);
        }
        Glide.with(mContext).load(listBean.getCover()).crossFade().placeholder(R.mipmap.icon_jishi_def).
                into((ImageView) baseViewHolder.getView(R.id.iv_cover));

        RecyclerView rv_girl = baseViewHolder.getView(R.id.rv_girl);
        baseViewHolder.setText(R.id.tv_num, String.valueOf(listBean.getNo()) + "号")
                .setText(R.id.tv_age, String.valueOf(listBean.getAge()) + "岁")
                .setText(R.id.tv_height, String.valueOf(listBean.getHeight()) + "cm")
                .setText(R.id.tv_weight, String.valueOf(listBean.getWeight() + "kg"))
                .setText(R.id.tv_bust, String.valueOf(listBean.getBust()))
                .setText(R.id.tv_waistline, String.valueOf(listBean.getWaistline()))
                .setText(R.id.tv_hips, String.valueOf(listBean.getHips()))
                .addOnClickListener(R.id.iv_cover)
                .addOnClickListener(R.id.iv_hips).addOnClickListener(R.id.tv_edit).addOnClickListener(R.id.tv_del);
        List<ShopTechnicianEntity.DataBean.ListBean.TagsBean> tags = listBean.getTags();


        initTagsAdapter(rv_girl, tags);
    }

    private void initTagsAdapter(RecyclerView rv_girl, List<ShopTechnicianEntity.DataBean.ListBean.TagsBean> tags) {
        ShopTechnicianTagAdapter shopTechnicianTagAdapter = new ShopTechnicianTagAdapter(mContext);
        rv_girl.setLayoutManager(new GridLayoutManager(mContext, 4));
        shopTechnicianTagAdapter.setNewData(tags);
        rv_girl.setAdapter(shopTechnicianTagAdapter);
    }

    public void setAdapter(ShopTechnicianTagAdapter shopTechnicianTagAdapter) {
        ShopTechnicianTagAdapter shopTechnicianTagAdapter1 = shopTechnicianTagAdapter;
    }
}
